

package Presentacion;

import javax.swing.JOptionPane;


public class NuevoEmpleado extends javax.swing.JInternalFrame {
      Control cLocal = new Control();
      
      public NuevoEmpleado() {
            initComponents();
      }

      
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
      private void initComponents() {

            btnAceptar = new javax.swing.JButton();
            btnCancelar = new javax.swing.JButton();
            txtDni = new javax.swing.JTextField();
            txtNombre = new javax.swing.JTextField();
            lblEncabezado = new javax.swing.JLabel();
            lblNombre = new javax.swing.JLabel();
            lblDNI = new javax.swing.JLabel();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            jLabel4 = new javax.swing.JLabel();
            jLabel5 = new javax.swing.JLabel();
            jLabel6 = new javax.swing.JLabel();
            txtFechaNacimiento = new javax.swing.JTextField();
            txtEmail = new javax.swing.JTextField();
            txtEstadoCivil = new javax.swing.JTextField();
            txtCantidadDeHijos = new javax.swing.JTextField();
            txtFechaIngreso = new javax.swing.JTextField();
            txtNumeroDeLegajo = new javax.swing.JTextField();

            btnAceptar.setText("Aceptar");
            btnAceptar.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                        btnAceptarActionPerformed(evt);
                  }
            });

            btnCancelar.setText("Cancelar");
            btnCancelar.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                        btnCancelarActionPerformed(evt);
                  }
            });

            lblEncabezado.setText("Ingrese los datos del nuevo Empleado:");

            lblNombre.setText("Nombre:");

            lblDNI.setText("DNI:");

            jLabel1.setText("Fecha de nacimiento");

            jLabel2.setText("e-mail");

            jLabel3.setText("Estado Civil");

            jLabel4.setText("Cantidad de hijos");

            jLabel5.setText("Fecha de ingreso");

            jLabel6.setText("Numero de legajo");

            txtNumeroDeLegajo.setText("jTextField1");
            txtNumeroDeLegajo.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                        txtNumeroDeLegajoActionPerformed(evt);
                  }
            });

            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addComponent(lblEncabezado)
                              .addGroup(layout.createSequentialGroup()
                                    .addGap(209, 209, 209)
                                    .addComponent(btnAceptar)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(btnCancelar))
                              .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                          .addComponent(lblNombre)
                                          .addComponent(lblDNI)
                                          .addComponent(jLabel1)
                                          .addComponent(jLabel2)
                                          .addComponent(jLabel3)
                                          .addComponent(jLabel4)
                                          .addComponent(jLabel5)
                                          .addComponent(jLabel6))
                                    .addGap(24, 24, 24)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                          .addComponent(txtDni)
                                          .addComponent(txtNombre)
                                          .addComponent(txtFechaNacimiento)
                                          .addComponent(txtEmail)
                                          .addComponent(txtEstadoCivil)
                                          .addComponent(txtCantidadDeHijos)
                                          .addComponent(txtFechaIngreso)
                                          .addComponent(txtNumeroDeLegajo, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))))
                        .addContainerGap(147, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblEncabezado)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(lblDNI)
                              .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(lblNombre)
                              .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(jLabel1)
                              .addComponent(txtFechaNacimiento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(jLabel2)
                              .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(jLabel3)
                              .addComponent(txtEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(jLabel4)
                              .addComponent(txtCantidadDeHijos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(7, 7, 7)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(jLabel5)
                              .addComponent(txtFechaIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(jLabel6)
                              .addComponent(txtNumeroDeLegajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 113, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                              .addComponent(btnAceptar)
                              .addComponent(btnCancelar))
                        .addContainerGap())
            );

            pack();
      }// </editor-fold>//GEN-END:initComponents

      private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed
            long dni, b=0;
            String nombre, nombreLoc;
            
            if((!(txtNombre.getText().equals("")))&&(!(txtDni.getText().equals("")))){
                  try {
                        //cLocal.dameClientes();
                        dni = Long.valueOf(txtDni.getText());
                        nombre = txtNombre.getText();
                        
                        

                        cLocal.crearEmpleado(); 
                        this.hide();

                  } catch (NumberFormatException a){
                        String err = "DNI Invalido";
                        System.err.println(err);
                        JOptionPane.showMessageDialog(this, err, "Error de Carga", JOptionPane.ERROR_MESSAGE);
                  } catch (Exception e){
                        String err = "Ya existe un cliente con ese DNI.";
                        System.err.println(err);
                        JOptionPane.showMessageDialog(this, err, "Error de Carga", JOptionPane.ERROR_MESSAGE);
                  }
            }
      }//GEN-LAST:event_btnAceptarActionPerformed

      private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
            this.hide();
      }//GEN-LAST:event_btnCancelarActionPerformed

      private void txtNumeroDeLegajoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNumeroDeLegajoActionPerformed
            // TODO add your handling code here:
      }//GEN-LAST:event_txtNumeroDeLegajoActionPerformed


      // Variables declaration - do not modify//GEN-BEGIN:variables
      private javax.swing.JButton btnAceptar;
      private javax.swing.JButton btnCancelar;
      private javax.swing.JLabel jLabel1;
      private javax.swing.JLabel jLabel2;
      private javax.swing.JLabel jLabel3;
      private javax.swing.JLabel jLabel4;
      private javax.swing.JLabel jLabel5;
      private javax.swing.JLabel jLabel6;
      private javax.swing.JLabel lblDNI;
      private javax.swing.JLabel lblEncabezado;
      private javax.swing.JLabel lblNombre;
      private javax.swing.JTextField txtCantidadDeHijos;
      private javax.swing.JTextField txtDni;
      private javax.swing.JTextField txtEmail;
      private javax.swing.JTextField txtEstadoCivil;
      private javax.swing.JTextField txtFechaIngreso;
      private javax.swing.JTextField txtFechaNacimiento;
      private javax.swing.JTextField txtNombre;
      private javax.swing.JTextField txtNumeroDeLegajo;
      // End of variables declaration//GEN-END:variables
}
